<template>
    <!--左侧房源筛选-->
    <div class="lefMain">
        <!--左侧1-->
        <span class="leftTop">
            <span style="font-size: 18px;white-space: nowrap;color:#7a8df1;font-weight: 600;">{{ $t('text.Contract.l273') }}</span>
            <span class="df" @click="this.$router.push('/addInformation')">
                <img class="addImg" src="../../assets/images/add.svg">
                <div style="font-size: 13px;white-space: nowrap;">{{ $t('text.Contract.l274') }}</div>
            </span>
        </span>

        <div class="leftTopInput">
            <img class="img1" src="../../assets/images/search2.png" />
            <input :placeholder="$t('text.Contract.l275')" class="leftTop2Input" v-model="nameOrNo">
        </div>

        <!--左侧3-->
        <div v-if="!isLoad">
            <div class="leftTop2">
                <div class="df">
                    <img class="img2" src="../../assets/images/icon.png" />
                    <div class="time">
                        {{$t('text.Contract.l29')}}
                        <el-date-picker v-model="time" type="daterange" unlink-panels range-separator="-" start-placeholder="Start date" end-placeholder="End date" :size="'small'"
                            style="width: 100px;margin-left: 10px;" value-format="YYYY-MM-DD" />
                    </div>
                </div>

                <div class="df">
                    <img class="img2" src="../../assets/images/icon.png" />
                    <div class="items">
                        <RadioSelect :leftText="$t('text.Contract.l30')" :selectList="getSelectData('userStatus')" searchKey="status" @returnData="setData" @clearData="clearData">
                        </RadioSelect>
                    </div>
                </div>

            </div>
        </div>
        <div class="resetDiv">{{ $t('text.Contract.l32') }}</div>

    </div>

    <!--右侧房源列表-->
    <div class="rightMain">
        <!--右侧顶部导航-->
        <div class="rightTop">
            {{$t('text.Contract.l280')}}
        </div>
        <!--右侧房源数据列表-->
        <div class="rightContain">

            <div class="rightList" v-if="conyractList.length>0">
                <div class="eDataList" v-for="(item,index) of 30" :key="item">

                    <CommonImage class="dataImage"></CommonImage>

                    <div class="dataRight">
                        <div class="dataDom">
                            <div class="dataTitle">
                                <span :class="index%2==0?'tag1':'tag2'">{{index%2==0? $t('text.Contract.l278'): $t('text.Contract.l279')}}</span>买房最大的忌讳
                            </div>
                            <div class="dataValue">轮子哥 2023-10-20</div>
                        </div>

                        <div class="dataIconList">
                            <img src="../../assets/images/h68.svg" class="dataImgIcon">
                            <img src="../../assets/images/h69.svg" class="dataImgIcon">
                            <img src="../../assets/images/h70.svg" class="dataImgIcon">
                            <img src="../../assets/images/h71.svg" class="dataImgIcon">
                        </div>
                    </div>
                </div>
            </div>
            <div class="rightList" v-else>
                <div class="nulData">
                    {{ $t('text.Common.l67')}}
                </div>
            </div>
            <!--底部分页-->
            <div class="setPage">
                <el-pagination v-model:current-page="searchData.pageNo" v-model:page-size="searchData.pageSize" :page-sizes="[10, 15, 20, 30, 50]" layout="total, sizes, prev, pager, next, jumper"
                    :total="total" @size-change="handleSizeChange" @current-change="handleCurrentChange" />
            </div>
        </div>
    </div>
</template>
    
<script>
import RadioSelect from "../../components/select/RadioSelect.vue"
export default {
    name: "RealEstateInformation",
    components: {
        RadioSelect,
    },
    data() {
        return {
            searchData: {
                pageNo: 1,
                pageSize: 15,
            },
            isLoad: false,
            dictionaryTree: {},
            isReset: false,
            conyractList: [{}],
            total: 0,
            orgTreeList: [],
            jobSelect: [],
            time: "",
            nameOrNo: "",

            type: 0,
        }
    },
    mounted() {},
    methods: {
        //获取字典数据
        getSelectData(key) {
            const data = this.dictionaryTree[key]
            if (data != undefined) {
                return this.dictionaryTree[key]
            } else {
                return [
                    {
                        dictName: "全部",
                        dictValue: "-1",
                    },
                ]
            }
        },

        getAge(birthDate) {
            birthDate = new Date(birthDate)
            let now = new Date()
            let age = now.getFullYear() - birthDate.getFullYear()
            if (
                now.getMonth() < birthDate.getMonth() ||
                (now.getMonth() === birthDate.getMonth() && now.getDate() < birthDate.getDate())
            ) {
                age--
            }
            return age
        },

        //搜索数据
        search() {},

        //拼接单个子组件返回来的条件值
        setData(obj) {
            this.searchData = { ...this.searchData, ...obj }
            console.log(JSON.stringify(this.searchData))
        },

        //子组件选择了不限，进行删除指定字段
        clearData(obj) {
            const objKeys = Object.keys(obj)
            this.searchData = Object.keys(this.searchData).reduce((acc, key) => {
                if (!objKeys.includes(key)) {
                    acc[key] = this.searchData[key]
                }
                return acc
            }, {})
            console.log(JSON.stringify(this.searchData))
        },

        //重置
        reset() {
            this.searchData = {
                pageNo: 1,
                pageSize: 10,
            }
            this.isReset = !this.isReset
        },
        handleSizeChange(val) {
            this.searchData.pageSize = val
            this.search()
        },
        handleCurrentChange(val) {
            this.searchData.pageNo = val
            this.search()
        },

        setHouseType(type) {
            this.type = type
        },
    },
    watch: {
        searchData: {
            handler() {
                this.search()
            },
        },
        time() {
            if (this.time == null) {
                this.clearData({ entryTime_BEGIN: "", entryTime_END: "" })
            } else {
                let obj = { entryTime_BEGIN: this.time[0], entryTime_END: this.time[1] }
                this.searchData = { ...this.searchData, ...obj }
            }
        },
        nameOrNo() {
            let obj = { nameOrNo: this.nameOrNo }
            this.setData(obj)
        },
    },
    computed: {},
}
</script>
    
<style scoped>
.dataRight {
    white-space: nowrap;
    display: flex;
    flex-wrap: nowrap;
    flex: 1;
    margin-left: 20px;
    height: 100%;
    border-bottom: 1px solid #eee;
}
.dataIconList {
    display: flex;
    justify-content: center;
    align-items: center;
}

.dataImgIcon {
    width: 20px;
    height: 20px;
    margin-right: 10px;
}

.dataImage {
    width: 100px;
    height: 60px;
    border: 1px solid #f4f4f4;
}

.nulData {
    background-image: url("../../assets/images/nullData.svg");
    background-size: cover;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 25px;
    color: #979797;
}

.tag1 {
    border: 1px solid #54d2d0;
    padding: 0 10px;
    margin-right: 10px;
    border-radius: 4px;
    background: #54d2d029;
    color: #54d2d0;
    font-size: 12px;
}

.tag2 {
    border: 1px solid #f3f3f3;
    padding: 0 10px;
    margin-right: 10px;
    border-radius: 4px;
    background: #282a2a29;
    color: #767676;
    font-size: 12px;
}

.resetDiv {
    background: #6698ff;
    margin-top: 20px;
    padding: 5px 0;
    font-size: 13px;
    color: white;
    border-radius: 7px;
}

.leftTopInput {
    display: flex;
    width: 100%;
    position: relative;
    padding-top: 10px;
}
.df {
    display: flex;
    align-items: center;
    margin-top: 8px;
    margin-bottom: 2px;
}

.lefMain {
    min-width: 310px;
    padding: 15px;
    overflow: auto;
    background: white;
    margin-bottom: 30px;
    margin-right: 5px;
    box-shadow: 1px 10px 30px 4px #e9e9e9;
}

.rightContain {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
    background: white;
    margin: 0px 30px 30px 25px;
    position: relative;
    box-shadow: 1px 5px 10px 4px #e9e9e9;
}

.leftTop {
    color: #6698ff;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.leftTop2 {
    border: 1px solid #cecece;
    border-radius: 5px;
    padding: 10px;
    margin-top: 10px;
    position: relative;
}

.addImg {
    width: 15px;
    height: 15px;
    padding-right: 3px;
}

.img2 {
    width: 22px;
    height: 22px;
}

.items {
    margin-left: 15px;
    padding-top: 6px;
    padding-bottom: 6px;
    font-size: 12px;
    color: gray;
    border-bottom: 1px solid rgb(224, 224, 224);
    width: 100%;
}
.rightMain {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    background: #f8f8f8;
}

.rightList {
    height: 100%;
    display: flex;
    flex-direction: column;
    border-radius: 5px;
    overflow: auto;
    padding: 10px 0;
}

.rightTop {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #eeeff4;
    margin: 15px 30px 0px 25px;
    color: black;
    font-size: 15px;
    height: 40px;
}

.setPage {
    display: flex;
    justify-content: flex-end;
    border-top: 1px solid #eee;
    padding: 10px;
}

.out {
    display: flex;
    align-items: center;
    font-size: 14px;
}

.outImg {
    width: 20px;
    height: 20px;
    padding-right: 5px;
}

.img2 {
    width: 22px;
    height: 22px;
}

.time {
    margin-left: 15px;
    padding-top: 6px;
    padding-bottom: 6px;
    font-size: 12px;
    color: gray;
    border-bottom: 1px solid rgb(224, 224, 224);
    width: 100%;
    display: flex;
    align-items: center;
    white-space: nowrap;
    justify-content: space-between;
}

.img1 {
    position: absolute;
    left: 7px;
    width: 15px;
    height: 15px;
    top: 17px;
    z-index: 1;
}

.leftTop2Input {
    outline: none;
    width: inherit;
    height: 25px;
    border: 1px solid rgb(220, 223, 230);
    padding-left: 23px;
    padding-right: 20px;
    background-color: rgb(242, 242, 242);
    border-radius: 5px;
    font-size: 12px;
    position: relative;
}

.leftTop2Input:focus {
    border: 1px solid #6698ff;
}

.eDataList {
    display: flex;
    align-items: flex-start;
    padding: 5px 30px;
    margin: 3px 0px;
    position: relative;
}

.eDataList:hover {
    background: #eee;
}

.dataTitle {
    font-size: 13px;
    color: black;
    padding-bottom: 10px;
}

.dataValue {
    font-size: 13px;
    color: #5c5c5c;
    display: flex;
    flex-wrap: wrap;
}
.dataValue > span {
    margin-right: 5px;
    margin-bottom: 5px;
    white-space: nowrap;
}
.dataDom {
    flex: 1;
    text-align: left;
    padding-bottom: 5px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}
</style>